<?php
	/**
	 * Horizontal multi-level menu class
	 *
	 */
	class HorizontalMenu
	{
		/**
		 * Creates menu item code
		 *
		 * @param array $item menu item or items' collection. Each item can have the following fields: url(menu item link), class (css class), tip (tooltip), text (text to display), attributes (html attributes for the link tag), sub (the array of menu items [recursion]).
		 */
		static function CreateMenuItem(array $item)
		{
			if (!empty($item[sub]))
			{
				echo "<li><a href='$item[url]' class = '$item[class]' title = '$item[tip]' $item[attributes]>$item[text]</a>";
				echo "<ul>";
					foreach ($item[sub] as $sub)
					{
						self::CreateMenuItem($sub);
					}
				echo "</ul></li>";
			}
			else
			{
				echo "<li><a href='$item[url]' class = '$item[class]' title = '$item[tip]' $item[attributes]>$item[text]</a></li>";
			}
		}
		
		/**
		 * Creates a multi-level horizontal menu
		 *
		 * @param array $elements menu items
		 */
		static function CreateMenu(array $elements)
		{
			echo '<script language="JavaScript" type="text/javascript" src="/spherus_framework/core/classes/HorizontalMenu/c_config.js"></script>';
			echo '<script language="JavaScript" type="text/javascript" src="/spherus_framework/core/classes/HorizontalMenu/c_smartmenus.js"></script>';
			echo '<link type="text/css" rel="stylesheet" href="/./spherus_framework/core/classes/HorizontalMenu/horizontal_menu.css"/>';
			
			echo "<div class='clearFix' style='padding:0px; background:#FFFFFF;'>
				   <ul id='Menu1' class='MM' style='padding:0px; margin: 0px; background:#FFFFFF; border:1px solid #5c5c5c;'>";
			
			foreach ($elements as $element)
			{
				self::CreateMenuItem($element);
			}
			
			echo " </ul>
				  </div>";
		}
	}
?>